package com.objecteffects.ilmp.tumblr.method;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;

/**
 * @author Rusty Wright
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class User {
    private final String defaultPostFormat;
    private final int following;
    private final String name;
    private final int likes;
    private final List<Blog> blogs = new ArrayList<>();

    public User(@JsonProperty("default_post_format")
    final String _defaultPostFormat, @JsonProperty("following")
    final int _following, @JsonProperty("name")
    final String _name, @JsonProperty("likes")
    final int _likes, @JsonProperty("blogs")
    final Blog[] _blogs) {
        super();
        this.defaultPostFormat =
            StringUtils.defaultIfBlank(_defaultPostFormat, "");
        this.name = StringUtils.defaultIfBlank(_name, "");
        this.likes = _likes;
        this.following = _following;
        this.blogs.addAll(Arrays.asList(_blogs));
    }

    // @JsonIgnore
    private final Map<String, Object> additionalProperties = new HashMap<>();

    @JsonProperty("default_post_format")
    public String getdefaultPostFormat() {
        return this.defaultPostFormat;
    }

    @JsonProperty("following")
    public int getfollowing() {
        return this.following;
    }

    @JsonProperty("name")
    public String getName() {
        return this.name;
    }

    @JsonProperty("likes")
    public int getLikes() {
        return this.likes;
    }

    @JsonProperty("blogs")
    public List<Blog> getBlogs() {
        return this.blogs;
    }

    @JsonAnyGetter
    public Map<String, Object> getAdditionalProperties() {
        return this.additionalProperties;
    }

    @JsonAnySetter
    public void setAdditionalProperty(final String _name, final Object value) {
        this.additionalProperties.put(_name, value);
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }

    @Override
    public int hashCode() {
        return HashCodeBuilder.reflectionHashCode(this);
    }

    @Override
    public boolean equals(final Object other) {
        return EqualsBuilder.reflectionEquals(this, other);
    }
}
